package heima3_2.cn.osc.hold;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import net.oschina.app.R;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import de.hdodenhof.circleimageview.CircleImageView;
import heima3_2.cn.osc.base.BaseHolder;
import heima3_2.cn.osc.base.MyBaseAdapter;
import heima3_2.cn.osc.model.bean.ActiveBean;
import heima3_2.cn.osc.utils.Global;

/**
 * Created by yaozhanlie on 2017/1/18.
 */

public class CommentHolder extends BaseHolder<ActiveBean> {
    @Bind(R.id.civ_comment_photo)
    CircleImageView mCivCommentPhoto;
    @Bind(R.id.tv_comment_name)
    TextView mTvCommentName;
    @Bind(R.id.tv_comment_dynamic)
    TextView mTvCommentDynamic;
    @Bind(R.id.tv_comment_content)
    TextView mTvCommentContent;
    @Bind(R.id.tv_comment_reply)
    TextView mTvCommentReply;
    @Bind(R.id.tv_comment_mobile)
    TextView mTvCommentMobile;
    @Bind(R.id.tv_comment_time)
    TextView mTvCommentTime;
    @Bind(R.id.comment_item)
    RelativeLayout mCommentItem;

    public CommentHolder(Context context, ViewGroup parent, MyBaseAdapter<ActiveBean> adapter, int position, ActiveBean bean) {
        super(context, parent, adapter, position, bean);
    }

    @Override
    public View onCreateView(Context context, ViewGroup parent, int position, ActiveBean bean) {
        View view = Global.inflats(R.layout.item_msg_comment);
        ButterKnife.bind(this,view);
        return view;
    }

    @Override
    protected void onRefreshView(ActiveBean bean, int position) {
        mTvCommentName.setText(bean.getAuthor());
        mTvCommentContent.setText(bean.getMessage());
        mTvCommentReply.setText(bean.getObjectreply().getObjectname()+": "+bean.getObjectreply().getObjectbody());
        mTvCommentTime.setText(bean.getPubDate());
        Picasso.with(context).load(bean.getPortrait()).resize(50, 50).centerCrop().into(mCivCommentPhoto);
    }

    @OnClick({R.id.civ_comment_photo, R.id.comment_item})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.civ_comment_photo:
                Global.showToast("进入用户中心");
                break;
            case R.id.comment_item:
                Global.showToast("进入动弹详情");
                break;
        }
    }
}
